package com.binance.notification.web.service.abnormaltrade.convert;

import java.util.List;

import com.binance.notification.web.service.abnormaltrade.models.AbnormalTradeNoticeLogBo;
import org.apache.commons.lang.StringUtils;

/**
 * 价格异动推送信息转换器
 */
public class PriceBreakthoughsPushMessageConvertor {
    
    public static String wrapMessage(List<AbnormalTradeNoticeLogBo> abnormalTradeNoticeLogBoList) {
        String content = "";
        for (AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo : abnormalTradeNoticeLogBoList) {
            content += abnormalTradeNoticeLogBo.getSymbol() + ",";
            content += abnormalTradeNoticeLogBo.getQuoteAssetName() + ",";
            content += String.valueOf(abnormalTradeNoticeLogBo.getUpdateTime().getTime()) + ",";
            content += abnormalTradeNoticeLogBo.getBusinessType().name() + ",";
            if(StringUtils.isNotBlank(abnormalTradeNoticeLogBo.getBusinessData().get("priceChangePercent"))){
                content += abnormalTradeNoticeLogBo.getBusinessData().get("priceChangePercent") + ",";
            }else{
                content += "" + ",";
            }
            content += abnormalTradeNoticeLogBo.getDescCode().getDescKey() + ",";
            content += abnormalTradeNoticeLogBo.getBusinessData().get("pushFlag") + ",";
            content += abnormalTradeNoticeLogBo.getDescCode().getDescCode() + ";";
        }
        return content;
    }

//    public static String wrapMessage(List<AbnormalTradeNoticeLogBo> abnormalTradeNoticeLogBoList, String language) {
//        String content = "";
//        for (AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo : abnormalTradeNoticeLogBoList) {
//            content += abnormalTradeNoticeLogBo.getSymbol() + ",";
//            content += abnormalTradeNoticeLogBo.getQuoteAssetName() + ",";
//            content += String.valueOf(abnormalTradeNoticeLogBo.getUpdateTime().getTime()) + ",";
//            content += abnormalTradeNoticeLogBo.getBusinessType().name() + ",";
//            content += "" + ",";
//            if ("cn".equals(language)) {
//                content += abnormalTradeNoticeLogBo.getDescCode().getCnDesc() + ",";
//            } else {
//                content += abnormalTradeNoticeLogBo.getDescCode().getEnDesc() + ",";
//            }
//            content += abnormalTradeNoticeLogBo.getBusinessData().get("pushFlag") + ",";
//            content += abnormalTradeNoticeLogBo.getDescCode().getDescCode() + ";";
//        }
//        return content;
//    }

    public static String wrapMessage(AbnormalTradeNoticeLogBo abnormalTradeNoticeLogBo, String language) {
        String content = "";
        content += abnormalTradeNoticeLogBo.getSymbol() + ",";
        content += abnormalTradeNoticeLogBo.getQuoteAssetName() + ",";
        content += String.valueOf(abnormalTradeNoticeLogBo.getUpdateTime().getTime()) + ",";
        content += abnormalTradeNoticeLogBo.getBusinessType().name() + ",";
        if(StringUtils.isNotBlank(abnormalTradeNoticeLogBo.getBusinessData().get("priceChangePercent"))){
            content += abnormalTradeNoticeLogBo.getBusinessData().get("priceChangePercent") + ",";
        }else{
            content += "" + ",";
        }
        if ("cn".equals(language)) {
            content += abnormalTradeNoticeLogBo.getDescCode().getCnDesc() + ",";
        } else {
            content += abnormalTradeNoticeLogBo.getDescCode().getEnDesc() + ",";
        }
        content += abnormalTradeNoticeLogBo.getBusinessData().get("pushFlag") + ",";
        content += abnormalTradeNoticeLogBo.getDescCode().getDescCode() + ";";
        return content;
    }

}
